package socket;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * @author liyang
 * @version 1.0
 * @package socket
 * @file ForeachDemo.java
 * @description
 * @time 2024-04-02 21:39
 */
public class ForeachDemo {
    public static void main(String[] args) {
        //对集合的遍历：迭代器，新循环，foreach
        List<String> c = new ArrayList<>();
        c.add("one");
        c.add("two");
        c.add("tree");
        c.add("four");
        c = Collections.synchronizedList(c);

        for (String e:c){
            System.out.println(e);

        }

        c.forEach(System.out::println);

    }
}
